package com.thinkinghead.mahjongrecorder.data.connect;

import com.parse.ParseFile;
import com.parse.ParseUser;
import com.thinkinghead.mahjongrecorder.model.User;

public class ParseObjectConvertor {
	public static final String ARG_ITEM_ID = "item_id";
	
	public static final String TB_Detail = "Detail";
	public static final String TB_RECORD = "Record";
	
	public static final String RECORD_DT = "recorddt";
	public static final String RECORD_CR = "createdby";
	public static final String RECORD_P1 = "name_p1";
	public static final String RECORD_P2 = "name_p2";
	public static final String RECORD_P3 = "name_p3";
	public static final String RECORD_P4 = "name_p4";
	public static final String RECORD_RM = "remark";
	
	public static final String ATTR_PASS = "password";
	public static final String ATTR_STATUS = "status";
	public static final String ATTR_EMAIL = "email";
	public static final String ATTR_IMG_URL = "usr_img";
	
	public static User fnToSimpleUser(ParseUser pu){
		if(pu!=null){
			User r = new User();
			r.setObjectID(pu.getObjectId());
			r.setName(pu.getUsername());
			r.setStatus(pu.getString(ATTR_STATUS));
			ParseFile image = (ParseFile) pu.get(ATTR_IMG_URL);
			if (image != null) {
				r.setImageUrl(image.getUrl());
			}
			return r;
		}
		return null;
	}
}